package com.ljwm.dubbo.demo.provider;

import com.alibaba.dubbo.rpc.RpcContext;
import com.ljwm.dubbo.demo.DemoService;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by yuzhou on 2017/8/3.
 */
public class DemoServiceImpl implements DemoService {

  @Override
  public String sayHello(String name) {

    System.out.println("[" + new SimpleDateFormat("HH:mm:ss").format(new Date())
      + "] Hello " + name + ", request from consumer: " + RpcContext.getContext().getRemoteAddress());

    return "Hello " + name + ", response form provider: " + RpcContext.getContext().getLocalAddress();
  }
}
